 #ifndef EDGE_H
 #define EDGE_H

 #include <QGraphicsPathItem>

 #include "diagramitem.h"
#include <math.h>


 class QGraphicsPolygonItem;
 class QGraphicsPathItem;
 class QGraphicsScene;
 class QRectF;
 class QGraphicsSceneMouseEvent;
 class QPainterPath;

 class Edge : public QGraphicsPathItem
 {
 public:

	enum EdgeType { nonCovalent, covalentMo, covalentBond, stoichiometric, lossReactant, transcription,
	combination, firstFeature, nextFeature, cleavage, stimulation, requirement, inhibition, catalysis };
	
	QVector<QPointF> points;
	QList<Edge*> conEdges;
	QList<DiagramItem*> invisibleItems;
	
	DiagramItem *complex;
	DiagramItem *trans;
	bool isComplex;
	bool intrans;
	qreal startx, starty, endx, endy;
	QString myId;
	//QString name;  // for next version
	bool endUp;
	int startUp;
	bool branchRight;
	bool branchLeft;
	//QString notes;  // for next version
	//QString annotation;  // for next version

    Edge( DiagramItem *startItem, DiagramItem *endItem, EdgeType edgeType,
       QGraphicsItem *parent = 0, QGraphicsScene *scene = 0);

	void addEdge(Edge *arrow);
    int type() const { return Type; }
	QColor Color() const;
	EdgeType edgeType() const
         { return myEdgeType; }
    void setColor(QColor c);
	void setOldColor();
	QPainterPath shape() const;
 	void mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent);
	void mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent);
	void mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent);
	//void mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event);   // for next version
    void paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget = 0); 
	QPointF intersectStartItem();
	QPointF intersect();
	QVector<QPointF> trackDiagramItem();
	bool containPoint(const QLineF &line,const QPointF &p);
	void change();
	int distance(const QPointF &p1,const QPointF &p2);
	void reverse();
	QString returnEnumFirst(const int &num);
	QString returnEnumSecond(const int &num);
	 
    DiagramItem *startItem() const
         { return myStartItem; }
    DiagramItem *endItem() const
         { return myEndItem; }  

	 
 private:
     
	DiagramItem *myEndItem;
	DiagramItem *myStartItem;
	EdgeType myEdgeType;
        QColor myColor;
	QColor myOldColor;
        QPolygonF arrowHead, arrowHead2;

 };

 #endif
